home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 21
/
CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso
/
CUCD
/
Magazine
/
C_Tutorial
/
Part-9
/
wb2
/
menu.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-01-03
|
2KB
|
82 lines
#include "menu.h"
#include "visual.h"
#include<libraries/gadtools.h>
#include<stdio.h>
#include<clib/gadtools_protos.h>
#include<clib/intuition_protos.h>
/* Global record of our menu strip */
static struct Menu* menu = NULL;
/* Unset menu check mark */
void uncheckToolBar(struct Window* win)
{
struct MenuItem* item;
/* First, remove menu strip from window */
ClearMenuStrip(win);
/* 2,1 is Tool Bar item (see below) */
item = ItemAddress(menu, FULLMENUNUM(2,1,0));
/* Unset CHECKED flag */
item->Flags &= ~CHECKED;
/* Reattach menu strip to window */
ResetMenuStrip(win,menu);
}
/* Create the menu strip, using GadTools menu functions */
int createMenuStrip()
{
/* The description of our menus */
struct NewMenu mymenu[] =
{
{ NM_TITLE, "Project", 0, 0, 0, 0,},
{ NM_ITEM, "Load", "L", 0, 0, 0,},
{ NM_ITEM, "Save", "S", 0, 0, 0,},
{ NM_ITEM, NM_BARLABEL, 0, 0, 0, 0,},
{ NM_ITEM, "New", "W", 0, 0, 0,},
{ NM_ITEM, NM_BARLABEL, 0, 0, 0, 0,},
{ NM_ITEM, "Quit", "Q", 0, 0, 0,},
{ NM_TITLE, "Pen", 0, 0, 0, 0,},
{ NM_ITEM, "Next", "N", 0, 0, 0,},
{ NM_ITEM, "Prev", "P", 0, 0, 0,},
{ NM_ITEM, NM_BARLABEL, 0, 0, 0, 0,},
{ NM_ITEM, "Reset", "R", 0, 0, 0,},
{ NM_TITLE, "Tools", 0, 0, 0, 0,},
{ NM_ITEM, "Screen Bar", "C", CHECKIT | MENUTOGGLE | CHECKED, 0, 0,},
/* Next item is index (2,1,0), see uncheckToolBar() above */
{ NM_ITEM, "Tool Bar", "T", CHECKIT | MENUTOGGLE | CHECKED, 0, 0,},
{ NM_END, NULL, 0, 0, 0, 0,},
};
if (menu = CreateMenus(mymenu, TAG_END))
{
APTR vinfo = getVisual();
if (LayoutMenus(menu, vinfo, TAG_END))
/* Succeeded */
return TRUE;
else
printf("Error: could not layout menus\n");
}
else
printf("Error: could not create menu strip\n");
/* Failed */
return FALSE;
}
void freeMenuStrip()
{
if(menu)
{
FreeMenus(menu);
/* Set to NULL to indicate that it's been freed */
menu = NULL;
}
}
/* Give access to the private menu */
struct Menu* getMenuStrip()
{
return menu;
}